package com.carey.yygh.hosp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.carey.yygh.common.exception.YyghException;
import com.carey.yygh.common.result.ResultCodeEnum;
import com.carey.yygh.hosp.service.HospitalSetService;
import com.carey.yygh.hosp.mapper.HospitalSetMapper;
import com.carey.yygh.model.hosp.HospitalSet;
import com.carey.yygh.vo.order.SignInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author carey-
* @description 针对表【hospital_set(医院设置表)】的数据库操作Service实现
* @createDate 2022-05-09 16:57:23
*/
@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet>
    implements HospitalSetService {

    @Autowired
    HospitalSetMapper hospitalSetMapper;
    @Override
    public String getSignKey(String hoscode) {
        QueryWrapper<HospitalSet> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("hoscode",hoscode);
        HospitalSet hospitalSet = hospitalSetMapper.selectOne(queryWrapper);
        System.out.println(hospitalSet.getSignKey());
        return hospitalSet.getSignKey();
    }

    @Override
    public SignInfoVo getSignInfoVo(String hoscode) {
        QueryWrapper<HospitalSet> wrapper = new QueryWrapper<>();
        wrapper.eq("hoscode",hoscode);
        HospitalSet hospitalSet = hospitalSetMapper.selectOne(wrapper);
        if (null == hospitalSet){
            throw new YyghException(ResultCodeEnum.DATA_ERROR);
        }
        SignInfoVo signInfoVo = new SignInfoVo();
        signInfoVo.setSignKey(hospitalSet.getSignKey());
        signInfoVo.setApiUrl(hospitalSet.getApiUrl());
        return signInfoVo;
    }
}




